#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;

template<class T>
class fenshu
{
public:
	fenshu(T a = 0,T b = 0):fz(a),fm(b){}
	~fenshu()
	{
		//cout << "data deleted" << endl;
	}
	void display()
	{
		cout << fz << "/" << fm << endl;
	}
	fenshu<T> sum(fenshu a,fenshu b);
	fenshu<T> sub(fenshu a, fenshu b);
	fenshu<T> mul(fenshu a, fenshu b);
	fenshu<T> div(fenshu a, fenshu b);
private:
	T fz;
	T fm;
};

template<class T>
fenshu<T> fenshu<T>::sum(fenshu a, fenshu b)
{
	fenshu<T> f(0,0);
	f.fm = a.fm + b.fm;
	f.fz = a.fz + b.fz;
	return f;
}

template<class T>
fenshu<T> fenshu<T>::sub(fenshu a, fenshu b)
{
	fenshu<T> f;
	f.fm = a.fm - b.fm;
	f.fz = a.fz - b.fz;
	return f;
}

template<class T>
fenshu<T> fenshu<T>::mul(fenshu a, fenshu b)
{
	fenshu<T> f;
	f.fm = a.fm * b.fm;
	f.fz = a.fz * b.fz;
	return f;
}

template<class T>
fenshu<T> fenshu<T>::div(fenshu a, fenshu b)
{
	fenshu<T> f;
	f.fm = a.fm * b.fz;
	f.fz = a.fz * b.fm;
	return f;
}

int main()
{
	fenshu<int>f1(1, 2);
	fenshu<int>f2(1, 2);
	fenshu<int>result(0,0);
	result = result.sum(f1, f2);
	result.display();
	result = result.sub(f1, f2);
	result.display();
	return 0;
}